package flexo.graphic.entity.particle;

import flexo.graphic.Color;
import flexo.graphic.entity.ParticleSystem;
import flexo.math.Vector;

public class Particle
{
	Color color;
	Vector origin;
	Vector position;
	float life;
	float maxLife;
	float size;
	ParticleSystem system;
	
	public Particle(ParticleSystem system)
	{
		this.system = system;
		origin = new Vector();
		position = new Vector();
		
		life = 0;
		color = new Color(1.0f,1.0f,1.0f,1.0f);
		
		// Particles start being invisible and dead
		kill();
	}
	
	public void kill()
	{
		reset(-1,0);
	}
	
	public void reset()
	{
		life = 0;
	}
	
	public void reset(float maxLife, float size)
	{
		reset();
		this.maxLife = maxLife;
		this.size = size;
	}
	
	public float getLifePercentage()
	{
		return life / maxLife;
	}
	
	public Color getColor()
	{
		return color;
	}
	
	public float getSize()
	{
		return size;
	}
	
	public void update(float elapsedTime)
	{
		life += elapsedTime;		
	}
	
	public boolean isDead()
	{
		return life > maxLife;
	}
	
	public Vector getPosition()
	{
		return position;
	}
	
	public Vector getOrigin()
	{
		return origin;
	}
}